import request from '@/axios'
import type { ListParams, Response } from '@/api/api'

export interface Row {
  id: number
  name: string
  parent_id: string
  order_num: string
  path: string
  component: string
  query: string
  is_frame: string
  menu_type: string
  visible: string
  perms: string
  icon: string
}

export interface FormData {
  id?: number
  name: string
  parent_id: string
  order_num: string
  path: string
  component: string
  query: string
  is_frame: string
  menu_type: string
  visible: string
  perms: string
  icon: string
}
// 菜单列表
export const getListApi = (data: ListParams): Promise<Response<Row>> => {
  return request.post({ url: '/user/menu/list', data })
}
// 菜单列表新增
export const createApi = (data: Partial<FormData>): Promise<IResponse> => {
  return request.post({ url: '/user/menu/create', data })
}
// 菜单列表编辑
export const modifyApi = (data: Partial<FormData>): Promise<IResponse> => {
  return request.post({ url: '/user/menu/modify', data })
}
// 菜单列表删除
export const delUserApi = (data: { id: string }): Promise<IResponse> => {
  return request.post({ url: '/user/menu/del', data })
}
// 菜单列表状态修改
export const updateStatusApi = (data: { status: string; id: string }): Promise<IResponse> => {
  return request.post({ url: '/user/menu/modify_status', data })
}
